
import QtQuick 1.0
//import Qt.labs.folderlistmodel 1.0

// prend exemple sur http://www.pluzz.fr/c-dans-l-air.html?sortie=rss
Rectangle {
    id: window
    color: "#3E606F"
    width: 480
    height: 400
    anchors.centerIn: parent
    focus: true
    
    function onSelectedPod(htmlSrc){
	console.log("selected**** :"  + htmlSrc );
    }
    
    ListModel {
	id : lModel
	ListElement {
	   name:"download"
	   icone: "images/download.jpg"
	   texte:"Télécharger"
	}

	ListElement {
	   name:"play"
	   icone: "images/play.jpg"
	   texte:"Jouer en Streaming"
	} 
	ListElement {
	   name:"streamPlay"
	   icone: "images/downloadPlay.jpg"
	   texte:"downLoad & Jouer"
	} 
   }
  
    
	  
    ListView {
	    id: listItems
	    //anchors.horizontalCenter: parent.horizontalCenter	   
	    focus: true
	    anchors.fill: parent
	    anchors.topMargin : 40
	    anchors.leftMargin : 100
	    spacing: 50
            model:lModel
            orientation:ListView.Vertical
	    //spacing:20
	    delegate : Rectangle {
				    color: "red"
				    id:delegateRect
				    //anchors.fill: parent
				    //smooth: true
				    //radius: 10
				    width: ListView.view.width-100; 
				    height: 60; 
				    anchors.leftMargin: 50; 
				    anchors.rightMargin: 30
				    Rectangle {
				      width:delegateRect.width-10;
				      anchors.leftMargin: 10; 
				      anchors.rightMargin: 10   
				      color:"#3E606F"
				      height:50
				      anchors.centerIn: parent
				      
				    }
				    Image {
					id:imgChoice; smooth: true
					fillMode: Image.PreserveAspectFit
					source:icone
					anchors.verticalCenter:delegateRect.verticalCenter
					width:50
					height:50
				      }
				      Text {
					id: txtDet
					anchors.left:imgChoice.right
					anchors.leftMargin: 40
					text: texte
					anchors.verticalCenter:delegateRect.verticalCenter
					color: "red"
					font.pixelSize: 20
				      }
				      
				      states: State {
						      name: "active"; when: activeFocus
						      PropertyChanges { target: delegateRect ; scale: 1.5 }
						  }
				      transitions: Transition {
						      NumberAnimation { properties: "scale"; duration: 300 }
						  }
				      Keys.onPressed: {
						  if (event.key == Qt.Key_Return) {
						      console.log("selected :"  + name );
						      onSelectedPod(name);
						      event.accepted = true;
						      /*if(foldermodel.isFolder(index)) {
							  console.log("dir:" + filePath);
							  foldermodel.folder=filePath;
							  event.accepted = true;
						      }else{
							console.log("file:" + filePath);
							event.accepted = true;
						      }*/
						  }
				      }
				  }
	}

        
}
 
